home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / windows / win31 / ssetup.arj / SETUP.CP_ / SETUP.CP
Text File  |  1993-12-23  |  51KB  |  1,355 lines

  1. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2. //
  3. //                SETUP.CPP
  4. //                Main file for "MAIN.EXE" Setup Studio sample program
  5. //                Use with CSETUP.DLL release 1.2.
  6. //
  7. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  8. //
  9. //                This file requires Microsoft Visual C++ Compiler and MFC 2.0 Library.
  10. //                Warning: You use this product at your own risk! You are responsible for making suitable backups in case it screws up. 
  11. //                You can use this file as a template and you can redistribute programs using this file ( Anyway, distributing
  12. //                this source code file without the full Unregistered Evaluation Copy of Setup Studio is forbidden ).
  13. //
  14. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  15. //
  16. //                There are 5 classes in this file:
  17. //
  18. //                        CSetupApp:        The application management 
  19. //                        CFirst:                  A splash dialog box with initialisation management
  20. //                        CMain:                The main application window which calls dialog boxes and GoSetup function
  21. //                        CChoice1:          To choose path and language
  22. //                        CChoice2:          To choose files to install
  23. //
  24. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  25. //                Remark:
  26. //              IDC_CHECKSSETUP correspond to the CTL3DAPI check box.
  27. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  28.  
  29.  
  30.  
  31.             // ----------------------------------------------------------
  32.             //  Private messages
  33.             // ----------------------------------------------------------
  34.             #define PM_FIRST        WM_USER + 0x048                // Message for CFirst Box to start the SetupInitialize
  35.             #define IDCHANGEPATH    36                                    // EndDialog value when user want to change the path on Choice2 box
  36.             
  37.             
  38.             // ----------------------------------------------------------
  39.             //  Include files
  40.             // ----------------------------------------------------------
  41.             #include "stdafx.h"
  42.             #include <stdlib.h>
  43.             #include <toolhelp.h>
  44.             #include <direct.h>
  45.             #include "setup.h"
  46.             #include "csetup.h"
  47.             #include <ctl3d.h>
  48.             
  49.             // ----------------------------------------------------------
  50.             //  Local functions
  51.             // ----------------------------------------------------------
  52.             void GiveTheHand( void );   
  53.             BOOL ExtractParameter( LPSTR szCommandLine, LPSTR szBuffer, int position );    // C programmers can use this function to retrieve Command Line parameters
  54.             void CenterDialogBox( HWND m_hWnd );   // Center a dialog Box
  55.                 
  56.             
  57.             
  58.             #ifdef _DEBUG
  59.             #undef THIS_FILE
  60.             static char BASED_CODE THIS_FILE[] = __FILE__;
  61.             #endif
  62.             
  63.             // ----------------------------------------------------------
  64.             //  Local variables
  65.             // ----------------------------------------------------------
  66.                 BOOL bIsSetupOK;                        // Result of SetupInitialize Function
  67.                 int iLanguage;                               // Language ( french or English )
  68.                 static char UserPath[160];                // Destination path
  69.                 int iType;                                         // User configuration = TYPE_VB, TYPE_TCW, TYPE_MFC or TYPE_NONE
  70.                 BOOL bConfiguration;                    // Indicate we have made a selection
  71.                 BOOL bBasic;                                // basic files are selected
  72.                 BOOL bCSetup;                                // DLL files are selected
  73.                 BOOL bDemo;                                    // Sample files are selected
  74.                 BOOL bHelp;                                      // Help files are selected
  75.                 BOOL bWizard;                               // Assistant files are selected
  76.                 BOOL bSSetup;                                // basic files are selected
  77.                 int UserConfigSize;                            // The size of the user' s selection
  78.                 static char szOriginalPath[160];             // First command line argument
  79.                 static char szTempSetupPath[160];        // Second command line argument
  80.             
  81.             
  82.             // ----------------------------------------------------------
  83.             //  Local constants
  84.             // ----------------------------------------------------------
  85.                 #define TYPE_VB                0              // Indicate Best path for VB users
  86.                 #define TYPE_TCW          1                // Indicate Best path for TCW users
  87.                 #define TYPE_MFC          2                // Indicate Best path for MFC users
  88.                 #define TYPE_NONE          3                // Normal path must be used
  89.             
  90.             
  91. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  92. // CSetupApp
  93. // Application implementation
  94. //
  95.             
  96.             // ----------------------------------------------------------
  97.             //  Message MAP
  98.             // ----------------------------------------------------------
  99.             BEGIN_MESSAGE_MAP(CSetupApp, CWinApp)
  100.                 //{{AFX_MSG_MAP(CSetupApp)
  101.                     // NOTE - the ClassWizard will add and remove mapping macros here.
  102.                     //    DO NOT EDIT what you see in these blocks of generated code !
  103.                 //}}AFX_MSG_MAP
  104.                 // Standard file based document commands
  105.             END_MESSAGE_MAP()
  106.             
  107.             // ----------------------------------------------------------
  108.             //  Constructor
  109.             // ----------------------------------------------------------
  110.             CSetupApp::CSetupApp()
  111.             {       
  112.             }
  113.             
  114.             // ----------------------------------------------------------
  115.             //  Application instanciation
  116.             // ----------------------------------------------------------
  117.             CSetupApp NEAR theApp;
  118.             
  119.             // ----------------------------------------------------------
  120.             //  Instance Initialization
  121.             // ----------------------------------------------------------
  122.             BOOL CSetupApp::InitInstance()
  123.             {
  124.                 SetDialogBkColor();                // set dialog background color to gray
  125.                 //LoadStdProfileSettings();       // Load standard INI file options (including MRU)
  126.                 EnableVBX();                          // Initialize VBX support
  127.             
  128.                 Ctl3dRegister( AfxGetInstanceHandle() );        // See CTL3D API
  129.                 bConfiguration = FALSE;
  130.                 UserConfigSize = 0;
  131.             
  132.                 // We need to retrieve the COMMAND line arguments
  133.                 if (m_lpCmdLine[0] != '\0')
  134.                     {
  135.                     ExtractParameter( m_lpCmdLine, (LPSTR)szOriginalPath, 1 );
  136.                     ExtractParameter( m_lpCmdLine, (LPSTR)szTempSetupPath, 2 );
  137.                     }
  138.                 else
  139.                     {
  140.                     ::MessageBox( NULL, "This program cannot be launched directly.\nSETUP.EXE must be used to to this.\n", "Setup", MB_OK | MB_ICONSTOP );
  141.                     return FALSE;
  142.                     }
  143.                     
  144.                 // Show initialization box
  145.                 CFirst boite1;
  146.                 boite1.DoModal();
  147.                 
  148.                 if ( bIsSetupOK )
  149.                     {
  150.                     CMain MainBox;
  151.                     MainBox.DoModal();
  152.                     }
  153.                 return TRUE;
  154.             }
  155.             
  156.             // ----------------------------------------------------------
  157.             //  Intance Exit ( like WEP )
  158.             // ----------------------------------------------------------
  159.             int CSetupApp::ExitInstance()
  160.             {
  161.             Ctl3dUnregister( AfxGetInstanceHandle() );
  162.             DeleteSystemDir(  );
  163.             return CWinApp::ExitInstance();
  164.             }
  165.             
  166.             // ----------------------------------------------------------
  167.             //  VBX Event MAP
  168.             // ----------------------------------------------------------
  169.             //{{AFX_VBX_REGISTER_MAP()
  170.             //}}AFX_VBX_REGISTER_MAP
  171.             
  172.             
  173.             
  174.             
  175.             
  176.             
  177. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  178. // CFirst dialog - Splash style and initialization managment
  179. //
  180.             
  181.             
  182.             
  183.             
  184.             // ----------------------------------------------------------
  185.             //  Constructor
  186.             // ----------------------------------------------------------
  187.             CFirst::CFirst(CWnd* pParent /*=NULL*/)
  188.                 : CDialog(CFirst::IDD, pParent)
  189.             {
  190.                 //{{AFX_DATA_INIT(CFirst)
  191.                     // NOTE: the ClassWizard will add member initialization here
  192.                 //}}AFX_DATA_INIT
  193.             }
  194.             
  195.             
  196.             
  197.             // ----------------------------------------------------------
  198.             //  Data Exchange
  199.             // ----------------------------------------------------------
  200.             void CFirst::DoDataExchange(CDataExchange* pDX)
  201.             {
  202.                 CDialog::DoDataExchange(pDX);
  203.                 //{{AFX_DATA_MAP(CFirst)
  204.                     // NOTE: the ClassWizard will add DDX and DDV calls here
  205.                 //}}AFX_DATA_MAP
  206.             }
  207.             
  208.             // ----------------------------------------------------------
  209.             //  Message MAP
  210.             // ----------------------------------------------------------
  211.             BEGIN_MESSAGE_MAP(CFirst, CDialog)
  212.                 //{{AFX_MSG_MAP(CFirst)
  213.                 ON_MESSAGE( PM_FIRST, OnFirstPrivate )
  214.                 ON_WM_CLOSE()
  215.                 //}}AFX_MSG_MAP
  216.             END_MESSAGE_MAP()
  217.             
  218.             
  219.             
  220.             // ----------------------------------------------------------
  221.             //  WM_INITDIALOG
  222.             //  Interface managment and Call OnFirstPrivate
  223.             // ----------------------------------------------------------
  224.             BOOL CFirst::OnInitDialog()
  225.             {
  226.                 CDialog::OnInitDialog();
  227.                 
  228.                 // TODO: Add extra initialization here
  229.                 SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) );
  230.                 Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL );
  231.                 CenterDialogBox( m_hWnd );
  232.                 BringWindowToTop();
  233.                 FirstCanClose = FALSE;
  234.                 PostMessage( PM_FIRST );
  235.                 return TRUE;  // return TRUE  unless you set the focus to a control
  236.             }
  237.             
  238.             
  239.             // ----------------------------------------------------------
  240.             //  PM_FIRST private message function
  241.             //  Guess the user Language 
  242.             //  Set interface
  243.             //  Call SetupInitialize
  244.             // ----------------------------------------------------------
  245.             afx_msg LRESULT CFirst::OnFirstPrivate( WPARAM wParam, LPARAM lParam )
  246.             {
  247.             static char far szTemp[6];                                                                                                
  248.             // Have a look in WIN.INI for Language detection
  249.             SendMessage( WM_PAINT );
  250.             GiveTheHand();
  251.             ::GetProfileString( "intl", "sLanguage", "", (LPSTR)szTemp, 4 );
  252.             AnsiUpper( szTemp );
  253.             if (lstrcmp( szTemp, "FRA" )== 0 )
  254.                 iLanguage = LANGUAGE_FRENCH;
  255.             else
  256.                 iLanguage = LANGUAGE_ENGLISH;
  257.                 
  258.             bIsSetupOK = SetupInitialize( "TEST", "", iLanguage, (LPSTR)szOriginalPath, (LPSTR)szTempSetupPath );
  259.                 GiveTheHand();
  260.                 
  261.             SetSharedBatchFile( "C:\\systest\\sytest.bat", "c:\\systest\\" );
  262.             SetPatternBrushStandard( BROSSE_3DCIRCLE );
  263.             SetBeepMode ( TRUE );            // Select or not the BEEP mode
  264.             SetTextLogo( "Setup Studio", "Arial", 52, RGB(192,192,192), TRUE, TRUE );  // Specifie the LOGO text
  265.             
  266.             SetLogoType( TRUE );            // If bTextType is TRUE, Setup will use the text as the LOGO, else it will use the bitmap.
  267.             SetVerifyMode( TRUE );            // Select or deselect the File Size Verification mode ( if size is bad, setup will abort ).
  268.             FirstCanClose = TRUE;
  269.                 
  270.             PostMessage( WM_CLOSE );
  271.             return TRUE;
  272.             }    
  273.             
  274.             
  275.             // ----------------------------------------------------------
  276.             //  WM_CLOSE
  277.             //    Do not close during Initialization
  278.             // ----------------------------------------------------------
  279.             void CFirst::OnClose()
  280.             {
  281.                 if ( FirstCanClose )                     // Disable user window closing during Initialisation....
  282.                     CDialog::OnClose();
  283.                 else
  284.                     MessageBeep( -1 );            
  285.             }
  286.                 
  287.                 
  288.                 
  289.             
  290.             
  291. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  292. // CMain dialog - In fact a pseudo dialog box only use with the ShowMainWindow CSETUP.DLL function
  293. //
  294.             
  295.             // ----------------------------------------------------------
  296.             //  Constructor
  297.             // ----------------------------------------------------------
  298.             CMain::CMain(CWnd* pParent /*=NULL*/)
  299.                 : CDialog(CMain::IDD, pParent)
  300.             {
  301.                 //{{AFX_DATA_INIT(CMain)
  302.                     // NOTE: the ClassWizard will add member initialization here
  303.                 //}}AFX_DATA_INIT
  304.             }
  305.             
  306.             // ----------------------------------------------------------
  307.             //  Data Exchange
  308.             // ----------------------------------------------------------
  309.             void CMain::DoDataExchange(CDataExchange* pDX)
  310.             {
  311.                 CDialog::DoDataExchange(pDX);
  312.                 //{{AFX_DATA_MAP(CMain)
  313.                     // NOTE: the ClassWizard will add DDX and DDV calls here
  314.                 //}}AFX_DATA_MAP
  315.             }
  316.             
  317.             // ----------------------------------------------------------
  318.             //  Message MAP
  319.             // ----------------------------------------------------------
  320.             BEGIN_MESSAGE_MAP(CMain, CDialog)
  321.                 //{{AFX_MSG_MAP(CMain)
  322.                 ON_MESSAGE( PM_FIRST, OnFirstPrivate )
  323.                 ON_MESSAGE( SN_NEWDISKREQUIRED, OnNewDisk )
  324.                 ON_WM_PAINT()
  325.                 ON_WM_NCPAINT()
  326.                 //}}AFX_MSG_MAP
  327.             END_MESSAGE_MAP()
  328.             
  329.             
  330.             
  331.             
  332.             
  333.             // ----------------------------------------------------------
  334.             //  WM_INITDIALOG
  335.             //    Call CMain::OnFirstPrivate
  336.             // ----------------------------------------------------------
  337.             BOOL CMain::OnInitDialog()
  338.             {
  339.                 CDialog::OnInitDialog();
  340.                 
  341.                 // TODO: Add extra initialization here
  342.                 SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) );
  343.                 SetWindowText( "Setup Studio 1.2 (c)");
  344.                 BringWindowToTop();
  345.                 PostMessage( PM_FIRST );
  346.                 return TRUE;  // return TRUE  unless you set the focus to a control
  347.             }
  348.             
  349.             
  350.             // ----------------------------------------------------------
  351.             //  CMain::PM_FIRST
  352.             //    Main function
  353.             // ----------------------------------------------------------
  354.             afx_msg LRESULT CMain::OnFirstPrivate( WPARAM wParam, LPARAM lParam )
  355.             {
  356.             CChoice1 box1( this );
  357.             CChoice2 box2( this );
  358.             int test1, test2, testmb;
  359.             static char szSecondPath[160];
  360.             static char szLogFile[160];
  361.             static char szTest[250];
  362.             int iResult, test;           
  363.             LPSTR testenv;
  364.             CString SrcHelpFile, DestHelpFile;
  365.                         
  366.             FIRSTBOX:                   
  367.             test1 = box1.DoModal();
  368.             if ( test1 == IDCANCEL )
  369.                 {
  370.                 if ( iLanguage == LANGUAGE_FRENCH )
  371.                     testmb = MessageBox( "Etes vous certain de vouloir\nabandonner l' installation?","Setup Studio", MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION );
  372.                 else
  373.                     testmb = MessageBox( "Are you sure you wish to abort\nthe installation program?","Setup Studio", MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION );
  374.                 if ( testmb == IDYES )
  375.                     goto END;
  376.                 else
  377.                     goto FIRSTBOX;
  378.                 }
  379.             SECONDBOX:
  380.             // We change the Bitmap to IDB_SETUP2
  381.             SetLogo( AfxGetInstanceHandle(), IDB_SETUP2 );        // Specifie a BITMAP to use as a LOGO ( LIGHT MAGENTA is transparent color ).
  382.             SetLogoType( FALSE );            // If bTextType is TRUE, Setup will use the text as the LOGO, else it will use the bitmap.
  383.             SendMessage( WM_PAINT );
  384.             test2 = box2.DoModal();
  385.             if ( test2 == IDCANCEL )
  386.                 {
  387.                 if ( iLanguage == LANGUAGE_FRENCH )
  388.                     testmb = MessageBox( "Etes vous certain de vouloir\nabandonner l' installation?","Setup Studio", MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION );
  389.                 else
  390.                     testmb = MessageBox( "Are you sure you wish to abort\nthe installation program?","Setup Studio", MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION );
  391.                 if ( testmb == IDYES )
  392.                     goto END;
  393.                 else
  394.                     {
  395.                     UserConfigSize=0;
  396.                     goto SECONDBOX;
  397.                     }
  398.                 }
  399.             if ( test2 == IDCHANGEPATH )
  400.                 {
  401.                 UserConfigSize=0;
  402.                 goto FIRSTBOX;
  403.                 }
  404.             SetLogo( AfxGetInstanceHandle(), IDB_SETUP3 );        // Specifie a BITMAP to use as a LOGO ( LIGHT MAGENTA is transparent color ).
  405.             SendMessage( WM_PAINT );
  406.             // Now we launch the installation
  407.             lstrcpy( szLogFile, UserPath );
  408.             lstrcat( szLogFile, "SETUP.LOG" );
  409.             SetLogFile( szLogFile );
  410.             // Simple directory   -------- WARNING: If you compile this file, for unregistered users, all directories belong to TEST root directory ---------
  411.             if ( bCSetup ) AddSectionToCopyList( "CSetup",  UserPath );
  412.             if ( bBasic ) AddSectionToCopyList( "Basic",  UserPath );
  413.             if ( bHelp ) AddSectionToCopyList( "Help",  UserPath );
  414.             if ( bWizard ) AddSectionToCopyList( "Wizard",  UserPath );
  415.             if ( bSSetup )
  416.                 {
  417.                 lstrcpy( szSecondPath, UserPath );
  418.                 lstrcat( szSecondPath, "CTL3D\\");
  419.                  AddSectionToCopyList( "CTL3D",  szSecondPath );
  420.                  }
  421.             if ( bDemo )
  422.                 {
  423.                 lstrcpy( szSecondPath, UserPath );
  424.                 lstrcat( szSecondPath, "SAMPLE\\");
  425.                  AddSectionToCopyList( (LPSTR)"Demo",  (LPSTR)szSecondPath );
  426.                  }
  427.                  
  428.             // Launch the installation
  429.             iResult = GoSetup( m_hWnd, TRUE );        // TRUE specifie we will use FINISH.EXE to clean up the temp dir when setup is complete
  430.             
  431.             
  432.             // Test the GoSetup returned value
  433.             if ( iResult ==   SETUP_SUCCESSFUL )
  434.                 {
  435.                 if ( bCSetup )
  436.                     {
  437.                     if ( iLanguage == LANGUAGE_FRENCH )
  438.                         test = MessageBox( "Souhaitez vous installer les icones\nde Setup Studio?", "Setup Studio", MB_YESNO | MB_ICONQUESTION );
  439.                     else
  440.                         test = MessageBox( "Do you wish to install Setup Studio icons?", "Setup Studio", MB_YESNO | MB_ICONQUESTION );
  441.                     if ( test == IDYES )            
  442.                         {
  443.                         CString IconPath;
  444.                         
  445.                         // First icon is the Wizard Icon
  446.                         IconPath = UserPath;
  447.                         IconPath += "SSTUDIO.EXE";
  448.                         if ( DoesFileExist( IconPath.GetBuffer(160), TRUE ) )
  449.                             {
  450.                             IconPath.ReleaseBuffer();
  451.                             if ( iLanguage == LANGUAGE_FRENCH )
  452.                                 {
  453.                                 AddItemToProgman("Setup Studio 1.2", IconPath.GetBuffer(160), "Setup Studio Wizard",   
  454. "Le Wizard est un assistant pour gΘrer les fichiers. Pour l' utiliser vous devrez modifier ses fichiers PIF et les copier dans le rΘpertoire de Windows." );
  455.                                 IconPath.ReleaseBuffer();
  456.                                 }
  457.                             else
  458.                                 {
  459.                                 IconPath.ReleaseBuffer();
  460.                                 AddItemToProgman("Setup Studio 1.2", IconPath.GetBuffer(160), "Setup Studio Wizard", 
  461. "Setup Studio Wizard is a tool to manage files an to create disks sets. To use it, you must edit PIF files and copy them in the Windows directory.");
  462.                                 IconPath.ReleaseBuffer();
  463.                                 }
  464.                              ShowWindow(SW_SHOWNORMAL );
  465.                             }
  466.                          else
  467.                             IconPath.ReleaseBuffer();
  468.                         }
  469.                             
  470.                         // User installs help files
  471.                         if ( bHelp )
  472.                             {
  473.                             SrcHelpFile = UserPath;
  474.                             if ( iLanguage == LANGUAGE_FRENCH )
  475.                                 SrcHelpFile += "FRSTUDIO.HLP" ;
  476.                             else
  477.                                 SrcHelpFile += "USSTUDIO.HLP";
  478.                             DestHelpFile = UserPath;
  479.                             DestHelpFile += "SSTUDIO.HLP";
  480.                             if ( DoesFileExist( DestHelpFile.GetBuffer(160), TRUE ) )
  481.                                 {
  482.                                 DestHelpFile.ReleaseBuffer();
  483.                                 DeleteFile( DestHelpFile.GetBuffer(160) );
  484.                                 DestHelpFile.ReleaseBuffer();
  485.                                 }
  486.                             else
  487.                                 DestHelpFile.ReleaseBuffer();
  488.                             RenameFile( SrcHelpFile.GetBuffer(160), DestHelpFile.GetBuffer(160) );
  489.                             SrcHelpFile.ReleaseBuffer();
  490.                             DestHelpFile.ReleaseBuffer();
  491.                             // We delete the not used help file
  492.                             SrcHelpFile = UserPath;
  493.                             if ( iLanguage == LANGUAGE_FRENCH )
  494.                                 SrcHelpFile += "USSTUDIO.HLP" ;
  495.                             else
  496.                                 SrcHelpFile += "FRSTUDIO.HLP";
  497.                             DeleteFile( SrcHelpFile.GetBuffer(160) );
  498.                             SrcHelpFile.ReleaseBuffer(); 
  499.                             }
  500.                             
  501.                         // Second icon is the Help file but we have to rename it before
  502.                         if ( ( bHelp ) && ( test == IDYES ))
  503.                             {
  504.                             if ( iLanguage == LANGUAGE_FRENCH )
  505.                                 AddItemToProgman("Setup Studio 1.2", DestHelpFile.GetBuffer(160), "Setup Studio Aide", 
  506.                                 "Ce fichier d' aide de 130 pages contient toutes les informations pour crΘer des programmes d' installation et pour utiliser les fonctions." );
  507.                             else
  508.                                 AddItemToProgman("Setup Studio 1.2", DestHelpFile.GetBuffer(160), "Setup Studio Help", 
  509.                                 "This 130 pages help file contains all necessary informations to build setup programs and to use functions." );
  510.                             DestHelpFile.ReleaseBuffer();
  511.                             ShowWindow(SW_SHOWNORMAL );
  512.                             }
  513.                       }    // User want to install icons
  514.                     // In case the wizard is installed, we create an associtaion
  515.                     if ( bWizard )
  516.                         {
  517.                         DestHelpFile = UserPath;
  518.                         DestHelpFile += "SSTUDIO.EXE";
  519.                         CreateWinFileAssociation( "LYT", DestHelpFile.GetBuffer(160) );
  520.                         DestHelpFile.ReleaseBuffer();
  521.                         }
  522.                         
  523.                      // The installation is complete, we allow the user to run the help file
  524.                         if ( bHelp )
  525.                             {
  526.                             if ( iLanguage == LANGUAGE_FRENCH )
  527.                                 test = MessageBox( "L' installation est terminΘe.\nVoulez vous parcourir le fichier\nd'aide maintenant?", "Setup",MB_YESNO | MB_ICONQUESTION ); 
  528.                             else
  529.                                 test = MessageBox( "The installation is complete.\nDo you want to have a look at\nthe help file now?", "Setup",MB_YESNO | MB_ICONQUESTION ); 
  530.                             if ( test == IDYES )
  531.                                 {
  532.                                 SrcHelpFile = UserPath;
  533.                                 SrcHelpFile += "SSTUDIO.HLP";
  534.                                 WinHelp( NULL, SrcHelpFile, HELP_CONTENTS, 0L );
  535.                                 }
  536.                             }
  537.                 }// Sucessful installation
  538.             else
  539.                 {
  540.                 if ( iLanguage == LANGUAGE_FRENCH )
  541.                     MessageBox( "L' installation est incomplΦte.\nPour utiliser ce produit, vous devrez\nl' installer α nouveau.", "Setup Studio", MB_OK | MB_ICONEXCLAMATION );
  542.                 else
  543.                     MessageBox( "Installation is not complete.\nPlease to use Setup Studio, install it again.", "Setup Studio", MB_OK | MB_ICONEXCLAMATION );
  544.                 }
  545.             END:    
  546.             PostMessage( WM_CLOSE );                          
  547.             return TRUE;
  548.             }
  549.             
  550.             
  551.             
  552.             // ----------------------------------------------------------
  553.             //  SN_NEWDISKREQUIRED
  554.             //    You will receive this message
  555.             //    when CSetup shows the New Disk
  556.             //    Required dialog box.
  557.             // ----------------------------------------------------------
  558.             afx_msg LRESULT CMain::OnNewDisk( WPARAM wParam, LPARAM lParam )
  559.             {
  560.             MessageBox( "New disk required ", (LPSTR)lParam );    /*You can use this message to Change the Logo for example*/
  561.             return TRUE;
  562.             };
  563.             
  564.             
  565.             // ----------------------------------------------------------
  566.             //  WM_PAINT
  567.             //    Call ShowMainWindow CSETUP.DLL function
  568.             // ----------------------------------------------------------
  569.             void CMain::OnPaint()
  570.             {                                 
  571.                 CPaintDC dc(this);                                                                                                                
  572.                 RedrawWindow( NULL, NULL, RDW_NOFRAME | RDW_NOERASE );  // To prevent flashing
  573.                 ShowMainWindow( m_hWnd );      // The main function wich paint your window as a Setup Like window ( for PAINT )
  574.                 RedrawWindow( NULL, NULL, RDW_NOFRAME | RDW_NOERASE );  // To prevent flashing
  575.             }
  576.             
  577.             
  578.             
  579.             // ----------------------------------------------------------
  580.             //  WM_PAINT
  581.             //    Call ShowMainWindow CSETUP.DLL function
  582.             // ----------------------------------------------------------
  583.             void CMain::OnNcPaint()
  584.             {
  585.                 RedrawWindow( NULL, NULL, RDW_NOERASE | RDW_VALIDATE );  // To prevent flashing 
  586.                 ShowMainWindow( m_hWnd );      // The main function wich paint your window as a Setup Like window ( for PAINT )
  587.                 RedrawWindow( NULL, NULL, RDW_NOERASE | RDW_VALIDATE );  // To prevent flashing 
  588.             }
  589.  
  590.  
  591.  
  592.  
  593.     
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  602. // CChoice1 dialog allows the user to choose Language and main Destination PATH
  603. //
  604.             
  605.             // ----------------------------------------------------------
  606.             //  Constructor
  607.             // ----------------------------------------------------------
  608.             CChoice1::CChoice1(CWnd* pParent /*=NULL*/)
  609.                 : CDialog(CChoice1::IDD, pParent)
  610.             {
  611.                 //{{AFX_DATA_INIT(CChoice1)
  612.                     // NOTE: the ClassWizard will add member initialization here
  613.                 //}}AFX_DATA_INIT
  614.             }
  615.             
  616.             
  617.             // ----------------------------------------------------------
  618.             //  Data Exchange ( not used )
  619.             // ----------------------------------------------------------
  620.             void CChoice1::DoDataExchange(CDataExchange* pDX)
  621.             {
  622.                 CDialog::DoDataExchange(pDX);
  623.                 //{{AFX_DATA_MAP(CChoice1)
  624.                     // NOTE: the ClassWizard will add DDX and DDV calls here
  625.                 //}}AFX_DATA_MAP
  626.             }
  627.             
  628.             // ----------------------------------------------------------
  629.             //  Message MAP
  630.             // ----------------------------------------------------------
  631.             BEGIN_MESSAGE_MAP(CChoice1, CDialog)
  632.                 //{{AFX_MSG_MAP(CChoice1)
  633.                 ON_BN_CLICKED(IDC_RADIOENGLISH, OnClickedRadioenglish)
  634.                 ON_BN_CLICKED(IDC_RADIOFRENCH, OnClickedRadiofrench)
  635.                 ON_EN_CHANGE(IDC_EDITSRCPATH, OnChangeEditsrcpath)
  636.                 //}}AFX_MSG_MAP
  637.             END_MESSAGE_MAP()
  638.             
  639.             
  640.             
  641.             // ----------------------------------------------------------
  642.             //  WM_INITDIALOG
  643.             //  Guess the best path for user
  644.             // ----------------------------------------------------------
  645.             BOOL CChoice1::OnInitDialog()
  646.             {
  647.                 CDialog::OnInitDialog();
  648.                 static char TempVBPath[160];
  649.                 
  650.                 // TODO: Add extra initialization here
  651.                 SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) );
  652.                 Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL );                              
  653.                 CenterDialogBox( m_hWnd );
  654.             
  655.                 // Dialog box initialization
  656.                 // We guess the client language thanks to WIN.INI
  657.                 
  658.                 if ( iLanguage == LANGUAGE_FRENCH )
  659.                     CheckRadioButton( IDC_RADIOENGLISH, IDC_RADIOFRENCH, IDC_RADIOFRENCH );
  660.                 else
  661.                     CheckRadioButton( IDC_RADIOENGLISH, IDC_RADIOFRENCH, IDC_RADIOENGLISH );
  662.                 if ( iLanguage == LANGUAGE_FRENCH )
  663.                     {
  664.                     SetDlgItemText( IDC_GROUPLANGUAGE, "Votre langage ");
  665.                     SetDlgItemText( IDC_TEXTE, "Indiquer le rΘpertoire ou vous souhaitez installer Setup Studio et cliquer sur OK:" );
  666.                     SetDlgItemText( IDCANCEL, "&Abandonner");
  667.                     }
  668.                 
  669.                 // Destination directory
  670.                 if ( lstrlen( UserPath ) > 0 )
  671.                     SetDlgItemText( IDC_EDITSRCPATH, UserPath );
  672.                 else
  673.                     {
  674.                     if ( DoesFileExist( "VB.INI", FALSE) )
  675.                         {
  676.                         lstrcpy( TempVBPath, GetWinFileAssociation( "FRM" ) );
  677.                         if ( lstrlen( TempVBPath) > 0 )
  678.                             {
  679.                             lstrcpyn( TempVBPath, TempVBPath, lstrlen( TempVBPath) - 5 ); // kill VB.EXE
  680.                             lstrcat( TempVBPath, "SSETUP" );
  681.                             lstrcpy( TempVBPath, FormatFileNameValid( TempVBPath, TRUE ) );
  682.                             AnsiUpper( TempVBPath );
  683.                             lstrcpy( UserPath, TempVBPath );
  684.                             iType = TYPE_VB;
  685.                             }
  686.                         }
  687.                     if ( DoesFileExist( "TCW.INI", FALSE) )
  688.                         {
  689.                         if ( lstrlen( TempVBPath) > 0 )
  690.                             {
  691.                             lstrcpy( TempVBPath, GetWinFileAssociation( "PRJ" ) );
  692.                             lstrcpyn( TempVBPath, TempVBPath, lstrlen( TempVBPath) - 10 ); // kill BIN\TCW.EXE
  693.                             lstrcat( TempVBPath, "SSETUP" );
  694.                             lstrcpy( TempVBPath, FormatFileNameValid( TempVBPath, TRUE ) );
  695.                             AnsiUpper( TempVBPath );
  696.                             lstrcpy( UserPath, TempVBPath );
  697.                             iType = TYPE_TCW;
  698.                             }
  699.                         }
  700.                     if ( DoesFileExist( "AUTOEXEC.BAT", FALSE) )
  701.                         {
  702.                         GetPrivateProfileString( "Microsoft Visual C++", "Path1", "", TempVBPath, 50, "MSVC.INI");
  703.                         if ( lstrlen( TempVBPath) > 0 )
  704.                             {
  705.                             lstrcpyn( TempVBPath, TempVBPath, lstrlen( TempVBPath) - 3 ); // kill BIN
  706.                             lstrcat( TempVBPath, "\\SSETUP" );
  707.                             lstrcpy( TempVBPath, FormatFileNameValid( TempVBPath, TRUE ) );
  708.                             AnsiUpper( TempVBPath );
  709.                             lstrcpy( UserPath, TempVBPath );
  710.                             iType = TYPE_MFC;
  711.                             }
  712.                         }                                        
  713.                     if ( lstrlen( UserPath ) < 1 )
  714.                         {
  715.                         lstrcpy( UserPath, "C:\\SSETUP\\" );
  716.                         iType = TYPE_NONE;
  717.                         }
  718.                     SetDlgItemText( IDC_EDITSRCPATH, UserPath );
  719.                     }
  720.                     
  721.                 (CEdit*)(GetDlgItem( IDC_EDITSRCPATH))->SetFocus(); 
  722.                 ((CEdit*)(GetDlgItem( IDC_EDITSRCPATH)))->SetSel( 0, -1 );
  723.                 return FALSE;  // return TRUE  unless you set the focus to a control
  724.             }
  725.             
  726.             
  727.             // ----------------------------------------------------------
  728.             //  WM_COMMAND:ONLANGUAGE
  729.             //  Change the language
  730.             // ----------------------------------------------------------
  731.             void CChoice1::OnClickedRadioenglish()
  732.             {
  733.                 // We reset the Language for all
  734.                 SetLanguage( LANGUAGE_ENGLISH );
  735.                 iLanguage = LANGUAGE_ENGLISH;
  736.                 SetDlgItemText( IDC_GROUPLANGUAGE, "Your language ");
  737.                 SetDlgItemText( IDC_TEXTE, "Please, give the directory in which you want to install Setup Studio files and click on OK" );
  738.                 SetDlgItemText( IDCANCEL, "&Abort");
  739.             }
  740.             
  741.             // ----------------------------------------------------------
  742.             //  WM_COMMAND:ONLANGUAGE
  743.             //  Change the language
  744.             // ----------------------------------------------------------
  745.             void CChoice1::OnClickedRadiofrench()
  746.             {
  747.                 SetLanguage( LANGUAGE_FRENCH );
  748.                 iLanguage = LANGUAGE_FRENCH;
  749.                 SetDlgItemText( IDC_GROUPLANGUAGE, "Votre langage ");
  750.                 SetDlgItemText( IDC_TEXTE, "Indiquer le rΘpertoire ou vous souhaitez installer Setup Studio et cliquer sur OK:" );
  751.                 SetDlgItemText( IDCANCEL, "&Abandonner");
  752.                         
  753.             }
  754.             
  755.             // ----------------------------------------------------------
  756.             //  WM_COMMAND:ONPATH
  757.             //  Change the path
  758.             // ----------------------------------------------------------
  759.             void CChoice1::OnChangeEditsrcpath()
  760.             {
  761.             static char TempDestName[160];
  762.                 GetDlgItemText( IDC_EDITSRCPATH, TempDestName, 160 );
  763.                 if ( lstrlen( TempDestName ) < 1 )
  764.                     GetDlgItem( IDOK)->EnableWindow( FALSE );
  765.                 else
  766.                     GetDlgItem( IDOK)->EnableWindow( TRUE );
  767.             }
  768.             
  769.             // ----------------------------------------------------------
  770.             //  WM_COMMAND:ONOK
  771.             //  Check the path thanks to
  772.             //    CSETUP functions
  773.             // ----------------------------------------------------------
  774.             void CChoice1::OnOK()
  775.             {
  776.             static char TempDestName[160];
  777.                 
  778.                 // We must check the directory
  779.                 GetDlgItemText( IDC_EDITSRCPATH, TempDestName, 160 );
  780.                 if ( !IsFileName( TempDestName, FILENAME_DIRWITHSLASH, CHECK_ROOTDIRSEXIST) )
  781.                     {
  782.                     lstrcpy( TempDestName, FormatFileNameValid( TempDestName, TRUE) );
  783.                     SetDlgItemText( IDC_EDITSRCPATH, TempDestName );
  784.                     }
  785.                 if ( IsFileName( TempDestName,  FILENAME_DIRWITHSLASH, CHECK_ROOTDIRSEXIST) )
  786.                     {
  787.                     lstrcpy( UserPath, TempDestName );
  788.                     CDialog::OnOK();
  789.                     }
  790.                 else
  791.                     {
  792.                     if ( iLanguage == LANGUAGE_FRENCH )
  793.                         MessageBox( "Le rΘpertoire mentionnΘ n' est pas valide.\nSi vous avez mentionnΘ des sous rΘpertoires\nceux ci doivent exister.\n", "Setup Studio", MB_OK | MB_ICONEXCLAMATION );
  794.                     else
  795.                         MessageBox( "Directory name is not valid.\nIf you want to specifie sub directories\nthey must exist.\n", "Setup Studio", MB_OK | MB_ICONEXCLAMATION );
  796.                     (CEdit*)(GetDlgItem( IDC_EDITSRCPATH))->SetFocus(); 
  797.                     ((CEdit*)(GetDlgItem( IDC_EDITSRCPATH)))->SetSel( 0, -1 );
  798.                     }
  799.             }
  800.             
  801.             
  802.             
  803.             
  804.             
  805.             
  806.             
  807. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  808. // CChoice2 dialog allows the user to select files to install
  809. //
  810.             
  811.             // ----------------------------------------------------------
  812.             //  Constructor
  813.             // ----------------------------------------------------------
  814.             CChoice2::CChoice2(CWnd* pParent /*=NULL*/)
  815.                 : CDialog(CChoice2::IDD, pParent)
  816.             {
  817.                 //{{AFX_DATA_INIT(CChoice2)
  818.                     // NOTE: the ClassWizard will add member initialization here
  819.                 //}}AFX_DATA_INIT
  820.             }
  821.             
  822.             // ----------------------------------------------------------
  823.             //  Data Exchange ( Not use )
  824.             // ----------------------------------------------------------
  825.             void CChoice2::DoDataExchange(CDataExchange* pDX)
  826.             {
  827.                 CDialog::DoDataExchange(pDX);
  828.                 //{{AFX_DATA_MAP(CChoice2)
  829.                     // NOTE: the ClassWizard will add DDX and DDV calls here
  830.                 //}}AFX_DATA_MAP
  831.             }
  832.             
  833.             // ----------------------------------------------------------
  834.             //  Message MAP
  835.             // ----------------------------------------------------------
  836.             BEGIN_MESSAGE_MAP(CChoice2, CDialog)
  837.                 //{{AFX_MSG_MAP(CChoice2)
  838.                 ON_BN_CLICKED(IDB_CHANGEPATH, OnClickedChangepath)
  839.                 ON_BN_CLICKED(IDC_CHECKBASIC, OnClickedCheckbasic)
  840.                 ON_BN_CLICKED(IDC_CHECKCSETUP, OnClickedCheckcsetup)
  841.                 ON_BN_CLICKED(IDC_CHECKDEMO, OnClickedCheckdemo)
  842.                 ON_BN_CLICKED(IDC_CHECKHELP, OnClickedCheckhelp)
  843.                 ON_BN_CLICKED(IDC_CHECKWIZARD, OnClickedCheckwizard)
  844.                 ON_BN_CLICKED(IDD_CHECKSSETUP, OnClickedCheckssetup)
  845.                 //}}AFX_MSG_MAP
  846.             END_MESSAGE_MAP()
  847.             
  848.             
  849.             
  850.             
  851.             // ----------------------------------------------------------
  852.             //  WM_INITDIALOG
  853.             //  Check boxes managment
  854.             // ----------------------------------------------------------
  855.             BOOL CChoice2::OnInitDialog()
  856.             {
  857.                 static char szTemp[12];    
  858.                 //long TotalSpace = 0L;
  859.                 CDialog::OnInitDialog();
  860.                 
  861.                 // TODO: Add extra initialization here
  862.                 SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) );
  863.                 Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL );
  864.                 CenterDialogBox( m_hWnd );
  865.                 BringWindowToTop();
  866.                 UserConfigSize = 0;
  867.                 // Set language
  868.                 if ( iLanguage == LANGUAGE_FRENCH )
  869.                     {
  870.                     SetDlgItemText( IDC_GROUP, "Installer... ");
  871.                     SetDlgItemText( IDC_CHECKBASIC, "Fichier header en basic");
  872.                     SetDlgItemText( IDC_CHECKCSETUP, "Setup Studio 1.2" );
  873.                     SetDlgItemText( IDC_CHECKDEMO, "Exemple ( version MFC )" );
  874.                     SetDlgItemText( IDC_CHECKHELP, "Fichier d' aide");
  875.                     SetDlgItemText( IDC_CHECKWIZARD, "Assistant");
  876.                     SetDlgItemText( IDD_CHECKSSETUP, "MS Ctl3d API");
  877.                     SetDlgItemText( IDC_TEXTECSIZE, "Taille de la sΘlection:");
  878.                     SetDlgItemText( IDC_TEXTETOTALSIZE, "Espace disponible:");
  879.                     SetDlgItemText( IDB_CHANGEPATH, "&RΘpertoire...");
  880.                     SetDlgItemText( IDOK, "OK" );
  881.                     SetDlgItemText( IDCANCEL, "&Abandonner" );
  882.                     }
  883.                 // Initialisation
  884.                 if ( !bConfiguration )                                                    // First initialisation
  885.                 {
  886.                 CheckDlgButton( IDC_CHECKCSETUP, TRUE );        
  887.                 CheckDlgButton( IDC_CHECKHELP, TRUE );        
  888.                 CheckDlgButton( IDC_CHECKWIZARD, TRUE );        
  889.                 if ( iType == TYPE_MFC )
  890.                     {
  891.                     CheckDlgButton( IDC_CHECKDEMO, TRUE );        
  892.                     CheckDlgButton( IDD_CHECKSSETUP, TRUE );        
  893.                     }
  894.                 if ( ( iType == TYPE_VB ) || ( iType == TYPE_NONE ) )
  895.                     CheckDlgButton( IDC_CHECKBASIC, TRUE );        
  896.                 }
  897.                 else
  898.                 {
  899.                 CheckDlgButton( IDC_CHECKCSETUP, bCSetup );        // Re initialisation of the dialog box
  900.                 CheckDlgButton( IDC_CHECKHELP, bHelp );        
  901.                 CheckDlgButton( IDC_CHECKWIZARD, bWizard );        
  902.                 CheckDlgButton( IDC_CHECKDEMO, bDemo );        
  903.                 CheckDlgButton( IDD_CHECKSSETUP, bSSetup );        
  904.                 CheckDlgButton( IDC_CHECKBASIC, bBasic );        
  905.                 }
  906.                 // Compute size of elements
  907.                 if ( IsDlgButtonChecked( IDC_CHECKCSETUP ) )
  908.                     {
  909.                     UserConfigSize += (int)GetSectionSize( "CSetup" );
  910.                     _itoa( (int)GetSectionSize("CSetup"), (LPSTR)szTemp, 10 );
  911.                     lstrcat( szTemp, " K");
  912.             //        MessageBox( szTemp );
  913.                     SetDlgItemText( IDC_KCSETUP, (LPSTR)szTemp );
  914.                     }
  915.                 if ( IsDlgButtonChecked( IDC_CHECKHELP ) )  
  916.                     {
  917.                     UserConfigSize += (int)GetSectionSize( "Help" );
  918.                     _itoa( (int)GetSectionSize("Help"), (LPSTR)szTemp, 10 );
  919.                     lstrcat( szTemp, " K");
  920.                     SetDlgItemText( IDC_KHELP, (LPSTR)szTemp );
  921.                     }
  922.                 if ( IsDlgButtonChecked( IDC_CHECKWIZARD ) )
  923.                     {
  924.                     UserConfigSize += (int)GetSectionSize( "Wizard" );
  925.                     _itoa( (int)GetSectionSize("Wizard"), (LPSTR)szTemp, 10 );
  926.                     lstrcat( szTemp, " K");
  927.                     SetDlgItemText( IDC_KWIZARD, (LPSTR)szTemp );
  928.                     }
  929.                 if ( IsDlgButtonChecked( IDC_CHECKDEMO ) )
  930.                     {
  931.                     UserConfigSize += (int)GetSectionSize( "Demo" );
  932.                     _itoa( (int)GetSectionSize("Demo"), (LPSTR)szTemp, 10 );
  933.                     lstrcat( szTemp, " K");
  934.                     SetDlgItemText( IDC_KDEMO, (LPSTR)szTemp );
  935.                     }
  936.                 if ( IsDlgButtonChecked( IDD_CHECKSSETUP ) )
  937.                     {
  938.                     UserConfigSize += (int)GetSectionSize( "CTL3D" );
  939.                     _itoa( (int)GetSectionSize("CTL3D"), (LPSTR)szTemp, 10 );
  940.                     lstrcat( szTemp, " K");
  941.                     SetDlgItemText( IDC_KMFC, (LPSTR)szTemp );
  942.                     }
  943.                 if ( IsDlgButtonChecked( IDC_CHECKBASIC ) )
  944.                     {
  945.                     UserConfigSize += (int)GetSectionSize( "Basic" );
  946.                     _itoa( (int)GetSectionSize("Basic"), (LPSTR)szTemp, 10 );
  947.                     lstrcat( szTemp, " K");
  948.                     SetDlgItemText( IDC_KBASIC, (LPSTR)szTemp );
  949.                     }
  950.                 // Total configuration space
  951.                 _itoa( UserConfigSize, szTemp, 10 );
  952.                 lstrcat( szTemp, " K");
  953.                 SetDlgItemText( IDC_KCONFIG, szTemp );
  954.                 // Disk free space
  955.                 _ltoa( AskForDriveSpace( GetDriveNumber( UserPath )), szTemp, 10 );
  956.                 lstrcat( szTemp, " K");
  957.                 SetDlgItemText( IDC_KTOTAL, szTemp );
  958.                         
  959.                 return TRUE;  // return TRUE  unless you set the focus to a control
  960.             }
  961.             
  962.             // ----------------------------------------------------------
  963.             //  WM_COMMAND:ONPATH
  964.             //  Save the configuration and 
  965.             //    Call the CChoice1 Dialog box
  966.             // ----------------------------------------------------------
  967.             void CChoice2::OnClickedChangepath()
  968.             {
  969.                     bConfiguration = TRUE;                                        // Indicate we have made a selection
  970.                     if ( IsDlgButtonChecked( IDC_CHECKBASIC ) )     // we save the current selection
  971.                          bBasic = TRUE;
  972.                     else
  973.                          bBasic = FALSE;
  974.                     if ( IsDlgButtonChecked( IDC_CHECKCSETUP ))      // we save the current selection
  975.                          bCSetup = TRUE;
  976.                     else
  977.                          bCSetup = FALSE;
  978.                     if ( IsDlgButtonChecked( IDC_CHECKDEMO )   )   // we save the current selection
  979.                          bDemo = TRUE;
  980.                     else
  981.                          bDemo = FALSE;
  982.                     if ( IsDlgButtonChecked( IDC_CHECKHELP )     ) // we save the current selection
  983.                          bHelp = TRUE;
  984.                     else
  985.                          bHelp = FALSE;
  986.                     if ( IsDlgButtonChecked( IDC_CHECKWIZARD )  )    // we save the current selection
  987.                          bWizard = TRUE;
  988.                     else
  989.                          bWizard = FALSE;
  990.                     if ( IsDlgButtonChecked( IDD_CHECKSSETUP )   )   // we save the current selection
  991.                          bSSetup = TRUE;
  992.                     else
  993.                          bSSetup = FALSE; 
  994.                 UserConfigSize = 0;
  995.                 EndDialog( IDCHANGEPATH );
  996.             }
  997.             
  998.             
  999.             // ----------------------------------------------------------
  1000.             //  WM_COMMAND:ONOK
  1001.             //  Check available disk size
  1002.             // ----------------------------------------------------------
  1003.             void CChoice2::OnOK()
  1004.             {
  1005.                 long ConfigurationSpace = 0L;
  1006.                 // TODO: Add extra validation here
  1007.                     bConfiguration = TRUE;                                        // Indicate we have made a selection
  1008.                     if ( IsDlgButtonChecked( IDC_CHECKBASIC ) )     // we save the current selection
  1009.                          bBasic = TRUE;
  1010.                     else
  1011.                          bBasic = FALSE;
  1012.                     if ( IsDlgButtonChecked( IDC_CHECKCSETUP ))      // we save the current selection
  1013.                          bCSetup = TRUE;
  1014.                     else
  1015.                          bCSetup = FALSE;
  1016.                     if ( IsDlgButtonChecked( IDC_CHECKDEMO )   )   // we save the current selection
  1017.                          bDemo = TRUE;
  1018.                     else
  1019.                          bDemo = FALSE;
  1020.                     if ( IsDlgButtonChecked( IDC_CHECKHELP )     ) // we save the current selection
  1021.                          bHelp = TRUE;
  1022.                     else
  1023.                          bHelp = FALSE;
  1024.                     if ( IsDlgButtonChecked( IDC_CHECKWIZARD )  )    // we save the current selection
  1025.                          bWizard = TRUE;
  1026.                     else
  1027.                          bWizard = FALSE;
  1028.                     if ( IsDlgButtonChecked( IDD_CHECKSSETUP )   )   // we save the current selection
  1029.                          bSSetup = TRUE;
  1030.                     else
  1031.                          bSSetup = FALSE;
  1032.                 // Check available space
  1033.                 if ( bBasic ) ConfigurationSpace = GetSectionSize( "Basic" );
  1034.                 if ( bCSetup ) ConfigurationSpace += GetSectionSize( "CSetup" );
  1035.                 if ( bDemo ) ConfigurationSpace += GetSectionSize( "Demo" );
  1036.                 if ( bHelp ) ConfigurationSpace += GetSectionSize( "Help" );
  1037.                 if ( bWizard ) ConfigurationSpace += GetSectionSize( "Wizard" );
  1038.                 if ( bSSetup ) ConfigurationSpace += GetSectionSize( "CTL3D" );
  1039.                 
  1040.                 if ( ConfigurationSpace > AskForDriveSpace( GetDriveNumber( UserPath )) )
  1041.                     {
  1042.                     if ( iLanguage == LANGUAGE_FRENCH )
  1043.                         MessageBox("Il n' y a pas assez d' espace libre\nsur l' unitΘ destination pour installer\nla sΘlection que vous avez choisi.\n\nVeuillez modifier votre sΘlection\nou changer de rΘpertoire."
  1044.                         , "Setup Studio", MB_OK | MB_ICONEXCLAMATION );
  1045.                     else
  1046.                         MessageBox("There is not enough free space\nto install selected files.\n\nPlease, change your selection\nor destination directory."
  1047.                         ,"Setup Studio", MB_OK | MB_ICONEXCLAMATION );
  1048.                     }
  1049.                 else
  1050.                     CDialog::OnOK();
  1051.                 
  1052.             }
  1053.             
  1054.             
  1055.             // ----------------------------------------------------------
  1056.             //  WM_COMMAND:ONBASIC
  1057.             //  Basic Check Box managment
  1058.             // ----------------------------------------------------------
  1059.             void CChoice2::OnClickedCheckbasic()
  1060.             {
  1061.             static char szTemp[10];// TODO: Add your control notification handler code here
  1062.                 if ( IsDlgButtonChecked( IDC_CHECKBASIC ) )
  1063.                     {
  1064.                     UserConfigSize += (int)GetSectionSize( "Basic" );
  1065.                     _itoa( (int)GetSectionSize("Basic"), (LPSTR)szTemp, 10 );
  1066.                     lstrcat( szTemp, " K");
  1067.                     SetDlgItemText( IDC_KBASIC, (LPSTR)szTemp );
  1068.                     _itoa( UserConfigSize, szTemp, 10 );
  1069.                     lstrcat( szTemp, " K");
  1070.                     SetDlgItemText( IDC_KCONFIG, szTemp );
  1071.                     }
  1072.                 else
  1073.                     {
  1074.                     UserConfigSize -= GetSectionSize( "Basic" );
  1075.                     SetDlgItemText( IDC_KBASIC, "0 K");
  1076.                     _itoa( UserConfigSize, szTemp, 10 );
  1077.                     lstrcat( szTemp, " K");
  1078.                     SetDlgItemText( IDC_KCONFIG, szTemp );
  1079.                     }
  1080.                 
  1081.             }
  1082.             
  1083.             // ----------------------------------------------------------
  1084.             //  WM_COMMAND:ONCSETUP
  1085.             //  CSetup Check Box managment
  1086.             // ----------------------------------------------------------
  1087.             void CChoice2::OnClickedCheckcsetup()
  1088.             {
  1089.                 // TODO: Add your control notification handler code here
  1090.             static char szTemp[10];// TODO: Add your control notification handler code here
  1091.                 if ( IsDlgButtonChecked( IDC_CHECKCSETUP ) )
  1092.                     {
  1093.                     UserConfigSize += (int)GetSectionSize( "CSetup" );
  1094.                     _itoa( (int)GetSectionSize("CSetup"), (LPSTR)szTemp, 10 );
  1095.                     lstrcat( szTemp, " K");
  1096.                     SetDlgItemText( IDC_KCSETUP, (LPSTR)szTemp );
  1097.                     _itoa( UserConfigSize, szTemp, 10 );
  1098.                     lstrcat( szTemp, " K");
  1099.                     SetDlgItemText( IDC_KCONFIG, szTemp );
  1100.                     }
  1101.                 else
  1102.                     {
  1103.                     UserConfigSize -= GetSectionSize( "CSetup" );
  1104.                     SetDlgItemText( IDC_KCSETUP, "0 K");
  1105.                     _itoa( UserConfigSize, szTemp, 10 );
  1106.                     lstrcat( szTemp, " K");
  1107.                     SetDlgItemText( IDC_KCONFIG, szTemp );
  1108.                     }
  1109.                 
  1110.                 
  1111.             }
  1112.             
  1113.             // ----------------------------------------------------------
  1114.             //  WM_COMMAND:ONDEMO
  1115.             //  Demo Check Box managment
  1116.             // ----------------------------------------------------------
  1117.             void CChoice2::OnClickedCheckdemo()
  1118.             {
  1119.                 // TODO: Add your control notification handler code here
  1120.             static char szTemp[10];// TODO: Add your control notification handler code here
  1121.                 if ( IsDlgButtonChecked( IDC_CHECKDEMO ) )
  1122.                     {
  1123.                     UserConfigSize += (int)GetSectionSize( "Demo" );
  1124.                     _itoa( (int)GetSectionSize("Demo"), (LPSTR)szTemp, 10 );
  1125.                     lstrcat( szTemp, " K");
  1126.                     SetDlgItemText( IDC_KDEMO, (LPSTR)szTemp );
  1127.                     _itoa( UserConfigSize, szTemp, 10 );
  1128.                     lstrcat( szTemp, " K");
  1129.                     SetDlgItemText( IDC_KCONFIG, szTemp );
  1130.                     }
  1131.                 else
  1132.                     {
  1133.                     UserConfigSize -= GetSectionSize( "Demo" );
  1134.                     SetDlgItemText( IDC_KDEMO, "0 K");
  1135.                     _itoa( UserConfigSize, szTemp, 10 );
  1136.                     lstrcat( szTemp, " K");
  1137.                     SetDlgItemText( IDC_KCONFIG, szTemp );
  1138.                     }
  1139.                 
  1140.                 
  1141.                 
  1142.             }
  1143.             
  1144.             // ----------------------------------------------------------
  1145.             //  WM_COMMAND:ONHELP
  1146.             //  Help Check Box managment
  1147.             // ----------------------------------------------------------
  1148.             void CChoice2::OnClickedCheckhelp()
  1149.             {
  1150.                 // TODO: Add your control notification handler code here
  1151.             static char szTemp[10];// TODO: Add your control notification handler code here
  1152.                 if ( IsDlgButtonChecked( IDC_CHECKHELP ) )
  1153.                     {
  1154.                     UserConfigSize += (int)GetSectionSize( "Help" );
  1155.                     _itoa( (int)GetSectionSize("Help"), (LPSTR)szTemp, 10 );
  1156.                     lstrcat( szTemp, " K");
  1157.                     SetDlgItemText( IDC_KHELP, (LPSTR)szTemp );
  1158.                     _itoa( UserConfigSize, szTemp, 10 );
  1159.                     lstrcat( szTemp, " K");
  1160.                     SetDlgItemText( IDC_KCONFIG, szTemp );
  1161.                     }
  1162.                 else
  1163.                     {
  1164.                     UserConfigSize -= GetSectionSize( "Help" );
  1165.                     SetDlgItemText( IDC_KHELP, "0 K");
  1166.                     _itoa( UserConfigSize, szTemp, 10 );
  1167.                     lstrcat( szTemp, " K");
  1168.                     SetDlgItemText( IDC_KCONFIG, szTemp );
  1169.                     }                                              
  1170.             }
  1171.             
  1172.             // ----------------------------------------------------------
  1173.             //  WM_COMMAND:ONWIZARD
  1174.             //  Wizard Check Box managment
  1175.             // ----------------------------------------------------------
  1176.             void CChoice2::OnClickedCheckwizard()
  1177.             {
  1178.             static char szTemp[10];// TODO: Add your control notification handler code here
  1179.                 if ( IsDlgButtonChecked( IDC_CHECKWIZARD ) )
  1180.                     {
  1181.                     UserConfigSize += (int)GetSectionSize( "Wizard" );
  1182.                     _itoa( (int)GetSectionSize("Wizard"), (LPSTR)szTemp, 10 );
  1183.                     lstrcat( szTemp, " K");
  1184.                     SetDlgItemText( IDC_KWIZARD, (LPSTR)szTemp );
  1185.                     _itoa( UserConfigSize, szTemp, 10 );
  1186.                     lstrcat( szTemp, " K");
  1187.                     SetDlgItemText( IDC_KCONFIG, szTemp );
  1188.                     }
  1189.                 else
  1190.                     {
  1191.                     UserConfigSize -= GetSectionSize( "Wizard" );
  1192.                     SetDlgItemText( IDC_KWIZARD, "0 K");
  1193.                     _itoa( UserConfigSize, szTemp, 10 );
  1194.                     lstrcat( szTemp, " K");
  1195.                     SetDlgItemText( IDC_KCONFIG, szTemp );
  1196.                     }                                                   
  1197.                 
  1198.             }
  1199.             
  1200.             // ----------------------------------------------------------
  1201.             //  WM_COMMAND:ONSSETUP
  1202.             //  SSetup Check Box managment
  1203.             // ----------------------------------------------------------
  1204.             void CChoice2::OnClickedCheckssetup()
  1205.             {
  1206.             static char szTemp[10];// TODO: Add your control notification handler code here
  1207.                 if ( IsDlgButtonChecked( IDD_CHECKSSETUP ) )
  1208.                     {
  1209.                     UserConfigSize += (int)GetSectionSize( "CTL3D" );
  1210.                     _itoa( (int)GetSectionSize("CTL3D"), (LPSTR)szTemp, 10 );
  1211.                     lstrcat( szTemp, " K");
  1212.                     SetDlgItemText( IDC_KMFC, (LPSTR)szTemp );
  1213.                     _itoa( UserConfigSize, szTemp, 10 );
  1214.                     lstrcat( szTemp, " K");
  1215.                     SetDlgItemText( IDC_KCONFIG, szTemp );
  1216.                     }
  1217.                 else
  1218.                     {
  1219.                     UserConfigSize -= GetSectionSize( "CTL3D" );
  1220.                     SetDlgItemText( IDC_KMFC, "0 K");
  1221.                     _itoa( UserConfigSize, szTemp, 10 );
  1222.                     lstrcat( szTemp, " K");
  1223.                     SetDlgItemText( IDC_KCONFIG, szTemp );
  1224.                     }
  1225.             }
  1226.             
  1227.             
  1228.             
  1229.             
  1230.             
  1231.             
  1232.             
  1233.             
  1234.             
  1235.             
  1236.             
  1237. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1238. //  Local functions
  1239.  
  1240.             
  1241.             // ----------------------------------------------------------
  1242.             //  GiveTheHand
  1243.             //    Let messages go on the system
  1244.             // ----------------------------------------------------------
  1245.             void GiveTheHand( void )
  1246.                 {                                                                                                    
  1247.                 MSG msg;
  1248.                 while ( PeekMessage( &msg, 0, 0, 0, PM_REMOVE) )
  1249.                     {
  1250.                     TranslateMessage( &msg );
  1251.                     DispatchMessage( &msg );
  1252.                     }
  1253.                 }
  1254.             
  1255.             
  1256.             
  1257.             
  1258.             
  1259.             
  1260.             
  1261.             // ----------------------------------------------------------
  1262.             //  ExtractParameter( LPSTR, Buffer, position )
  1263.             //    Extract the Command line parameters
  1264.             // ----------------------------------------------------------
  1265.             BOOL ExtractParameter( LPSTR szCommandLine, LPSTR szBuffer, int position )
  1266.                 {
  1267.                 LPSTR szTemp;
  1268.                 LPSTR pos;
  1269.                 LPSTR szStart= "0000";
  1270.                 LPSTR szStop = "00000";
  1271.                 BOOL test1 = FALSE;
  1272.                 BOOL test2 = FALSE;
  1273.                 HANDLE h1;                                                    
  1274.                 
  1275.                 char Mask =' ' ;
  1276.                 int i;                       
  1277.                                 
  1278.                  if ( (szBuffer == (LPSTR)NULL) || (szCommandLine == (LPSTR)NULL) )
  1279.                     return FALSE;
  1280.                 h1 = GlobalAlloc( LHND,(long) (lstrlen( szCommandLine ) + 3 ) );
  1281.                 szTemp = (LPSTR)GlobalLock(h1);
  1282.                 
  1283.                 lstrcpyn( szStart, szCommandLine, 2);
  1284.                 if ( lstrcmp( szStart, " " ) == 0 )
  1285.                     test1 = TRUE;
  1286.                 lstrcpyn( szStop, szCommandLine+ lstrlen( szCommandLine) - 1 , 2 );
  1287.                 if ( lstrcmp( szStop, " ") != 0 )
  1288.                     test2 = TRUE;
  1289.                 if ( (test1) && (test2))    
  1290.                     {
  1291.                     lstrcpy( szTemp, szCommandLine+1);
  1292.                     lstrcat( szTemp, " ");
  1293.                     }
  1294.                 else
  1295.                     {
  1296.                     if ( test1 )
  1297.                         lstrcpy( szTemp, szCommandLine+1 );
  1298.                     if ( test2 )
  1299.                         {
  1300.                         lstrcpy( szTemp, szCommandLine );
  1301.                         lstrcat( szTemp, " ");
  1302.                         }
  1303.                     if ( (!test1) && (!test2))                    
  1304.                         lstrcpy( szTemp, szCommandLine);
  1305.                     }
  1306.                 i=1;
  1307.                 for ( i=1; i <= position ; i++ )
  1308.                     {
  1309.                     pos = (LPSTR)_fmemchr(szTemp, ' ', lstrlen(szTemp) );
  1310.                     if ( (i== position) && ( (pos != NULL) || ( position == 1)))
  1311.                         {       
  1312.                            lstrcpyn(szBuffer, szTemp, (pos-szTemp)+1);
  1313.                         GlobalUnlock( h1 );
  1314.                         GlobalFree( h1 );
  1315.                         return TRUE;
  1316.                         }                                                                                           
  1317.                     else
  1318.                           {
  1319.                           if ( pos != NULL )
  1320.                                lstrcpy( szTemp, _fstrstr(szTemp," ")+1);
  1321.                            else
  1322.                             lstrcpy( szTemp, "");
  1323.                         }
  1324.                      }
  1325.                   lstrcpy( szBuffer, "");
  1326.                   GlobalUnlock( h1 );
  1327.                   GlobalFree( h1 );
  1328.                   return FALSE;
  1329.                   }
  1330.                         
  1331.                         
  1332.             // ----------------------------------------------------------
  1333.             //  CenterDialogBox( HWND )
  1334.             //    Absolute center a dialog box
  1335.             // ----------------------------------------------------------
  1336.             void CenterDialogBox( HWND m_hWnd )
  1337.             {            
  1338.             RECT rMain, rBox;
  1339.             int MainHeight, MainWidth, BoxHeight, BoxWidth;
  1340.             
  1341.             ::GetWindowRect( ::GetDesktopWindow(), &rMain );
  1342.             ::GetWindowRect( m_hWnd, &rBox );                                
  1343.             MainWidth = rMain.right - rMain.left ;
  1344.             BoxWidth = rBox.right - rBox.left ;
  1345.             MainHeight = rMain.bottom - rMain.top ;
  1346.             BoxHeight = rBox.bottom - rBox.top ;
  1347.             ::SetWindowPos( m_hWnd, (HWND)NULL, ( MainWidth / 2 ) - ( BoxWidth / 2 ), ( MainHeight / 2 ) - ( BoxHeight / 2 ), 
  1348.                 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW );
  1349.             }
  1350.                                             
  1351.                                             
  1352.                                             
  1353. //////////////////////////////////////////////// END OF THIS FILE ////////////////////////////////////////////////////////////////
  1354.                                 
  1355.